package com.aline.seo.repository;

import com.aline.seo.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName UserRepository
 * @Description 用户角色jpa
 * @Author 孟志浩
 * @Date 2019/4/9 15:02
 **/
@Repository
public interface UserRoleRepository extends JpaRepository<UserRole,Long> {

    @Query(value = "select r.name from t_role r inner join t_user_role ur on (r.id = ur.rid and ur.uid=:uid)", nativeQuery = true)
    List<String> findRoleByUserId(@Param("uid") Long uid);

}
